//引入所有modules下的文件
const modulesFiles = require.context('./modules', true, /.js$/)
let mocks = {}
modulesFiles.keys().forEach((modulePath) => {
    const value = modulesFiles(modulePath)
    mocks = { ...mocks, ...value.default }
	
})

export default function (params) {
    const strArr = params.url.split('?')[0].split('/')
    const name = strArr[strArr.length - 1]
    let res = { code: 404, data: {} }
    Object.keys(mocks).forEach(key => {
        if (name == key) {
            res.code = 200
            res.data.records = mocks[key]
        }
    })

    if (res.code != 200) {
        return false
    }

    return new Promise((resolve, reject) => {
        resolve(res)
    })
} 
